//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
// Portions Copyright (c) MiTAC Corp. All rights reserved.
//------------------------------------------------------------------------------
//
//  Header:  eboot.h
//
//  This header file is comprised of component header files that defines
//  the standard include hierarchy for the bootloader. It also defines few
//  trivial constant.
//
#ifndef __EBOOT_H
#define __EBOOT_H

//------------------------------------------------------------------------------

#include <windows.h>
#include <ceddk.h>
#include <blcommon.h>
#include <nkintr.h>
#include <halether.h>
#include <fmd.h>
#include <bootpart.h>

#include <oal.h>
#include <oal_blmenu.h>


#include <bsp_cfg.h>
#include <boot_args.h>
#include <args.h>
#include <image_cfg.h>
#include <memory.h>

//platform dependent header file
#include <bsp_oalkeys.h>
#include <Bsp_oaldisp.h> 
#include <bsp_oalprintk.h>
#include <s3c2443.h>

//------------------------------------------------------------------------------

#define EBOOT_VERSION_MAJOR         0
#define EBOOT_VERSION_MINOR         6

//------------------------------------------------------------------------------

typedef struct {
    UINT32 start;
    UINT32 length;
    UINT32 base;
} REGION_INFO_EX;

//------------------------------------------------------------------------------

#define DOWNLOAD_TYPE_UNKNOWN       0
#define DOWNLOAD_TYPE_RAM           1
#define DOWNLOAD_TYPE_BINDIO        2
#define DOWNLOAD_TYPE_XLDR          3
#define DOWNLOAD_TYPE_EBOOT         4
#define DOWNLOAD_TYPE_IPL           5
#define DOWNLOAD_TYPE_FLASHRAM      6
#define DOWNLOAD_TYPE_GSMFFS      7
#define DOWNLOAD_TYPE_GSM      8
#define DOWNLOAD_TYPE_BOOTLOADER      9
//------------------------------------------------------------------------------

typedef struct {
    OAL_KITL_TYPE bootDeviceType;
    UINT32 type;
    UINT32 numRegions;
    UINT32 launchAddress;
    REGION_INFO_EX region[BL_MAX_BIN_REGIONS];

    UINT32 recordOffset;
    UINT8  *pReadBuffer;
    UINT32 readSize;
    //Visual: for statistic
    UINT32 readtotal;
} EBOOT_CONTEXT;

//------------------------------------------------------------------------------
typedef enum{
KD_ID_USBSER=0x10,
KD_ID_IPL,
};

extern BOOT_CFG g_bootCfg;
extern EBOOT_CONTEXT g_eboot;
extern OAL_KITL_DEVICE g_bootDevices[];
extern OAL_KITL_DEVICE g_kitlDevices[];
extern OAL_KITL_DEVICE g_ModemDebugModes[];

//------------------------------------------------------------------------------

VOID OEMMultiBinNotify(MultiBINInfo *pInfo);

//------------------------------------------------------------------------------

VOID   BLMenu();    
BOOL   BLReadBootCfg(BOOT_CFG *pBootCfg);
BOOL   BLWriteBootCfg(BOOT_CFG *pBootCfg);
UINT32 BLEthDownload(BOOT_CFG *pBootCfg, OAL_KITL_DEVICE *pBootDevices);
VOID   BLEthConfig(BSP_ARGS *pArgs);
UINT32 BLFlashDownload(BOOT_CFG *pConfig, OAL_KITL_DEVICE *pBootDevices);
VOID*  BLVAtoPA(UINT32 address);

//------------------------------------------------------------------------------

#endif
